package com.ruoyi.lvlian.controller;

import java.util.List;

import com.ruoyi.lvlian.dto.Lv91CollectInfoBatchDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.lvlian.domain.Lv91CollectInfo;
import com.ruoyi.lvlian.service.ILv91CollectInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 浙江91入库单Controller
 *
 * @author liyuxi
 * @date 2024-06-03
 */
@RestController
@RequestMapping("/api")
public class ApiCollectInfoController extends BaseController {
    @Autowired
    private ILv91CollectInfoService lv91CollectInfoService;

    /**
     * 查询浙江91入库单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Lv91CollectInfo lv91CollectInfo) {
        startPage();
        List<Lv91CollectInfo> list = lv91CollectInfoService.selectLv91CollectInfoList(lv91CollectInfo);
        return getDataTable(list);
    }


    /**
     * 新增浙江91入库单
     */
    @PostMapping
    public AjaxResult add(@RequestBody Lv91CollectInfo lv91CollectInfo) {
        return toAjax(lv91CollectInfoService.insertLv91CollectInfo(lv91CollectInfo));
    }



    @PostMapping("/save91CollectInfo")
    public AjaxResult save91CollectInfo(@RequestBody Lv91CollectInfoBatchDto lv91CollectInfoBatchDTO) {

        int result = lv91CollectInfoService.insertLv91CollectInfoBatch(lv91CollectInfoBatchDTO);
        return toAjax(result);
    }



    /**
     * 修改浙江91入库单
     */
    @Log(title = "浙江91入库单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Lv91CollectInfo lv91CollectInfo) {
        return toAjax(lv91CollectInfoService.updateLv91CollectInfo(lv91CollectInfo));
    }

    /**
     * 删除浙江91入库单
     */
    @Log(title = "浙江91入库单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{collectIds}")
    public AjaxResult remove(@PathVariable String[] collectIds) {
        return toAjax(lv91CollectInfoService.deleteLv91CollectInfoByCollectIds(collectIds));
    }
}
